 <?php
$tp = $this->common_model->getdata('province', '', '', array(
	'order',
	'ASC'
));
$mon = $this->common_model->getdata('subjects',array('publish'=>1),array('id','title'),array('order','ASC'));
?>
  <script>
  $(document).ready(function() {
    var availableTags = [<?php
if(!empty($mon)) {
	$i = 0;
	$n = count($mon);
	foreach($mon as $mon) {
		if($i == $n) {
			echo '"' . $mon->title . '"';
		} else {
			echo '"' . $mon->title . '",';
		}
		$i++;
	}
}
?>];
    $( ".text_box1" ).autocomplete({
      source: availableTags,disabled: false,autoFocus:true,widget:true,delay:0
    });
  });
  </script>
<script>
        $(document).ready(function(){
        $('.btn_box1').on('click',function(){
            var tien1 = $('#amount').val();
            var tien2 = $('#amount2').val();
            var tuoi1 = $('#amount3').val();
            var tuoi2 = $('#amount4').val();
            var sub1 =$('#sub1').val();
            var sub2 =$('#sub2').val();
            var sub3 =$('#sub3').val();
            var city=$('#province').val();
            var dist=$('#district').val();
            var gender=$('#gender').val();
            $.ajax({
                  type: "POST",
                  url: '<?php echo base_url();?>ajax/search',
                  data: {tien1 : tien1,tien2:tien2,tuoi1:tuoi1,tuoi2:tuoi2,sub1:sub1,sub2:sub2,sub3:sub3,city:city,dist:dist,gender:gender },
                  success: success
                });
            });  
            return false;             
    });
    function success(data,status){
        $('.primary').html(data);
   }; 

</script>

<section class="cl_left">
			<div class="box1">
				<h3 class="title_box1">Tìm kiếm gia sư <i class="icon-search"></i></h3>
				<!-- /.title_box1 -->
				<div class="curent_box1">
					<p class="title1">Môn học</p>
					<input name="search" type="text" class="text_box1" id="sub1" value="<?php if(!empty($search)) echo $search; ?>" placeholder="VD : Toán" />
					<ul class="localtion_box1">
						<li>
							<label>
							<select name="search_box1" id="province" class="box1_select">
								<option value="0">Tỉnh - Thành phố</option>
                                    <?php
									if(!empty($tp)) {
										foreach($tp as $tp) {
											if(!empty($province) && $province == $tp->id){
												echo '<option selected value="' . $tp->id . '">' . $tp->title . '</option>';
											}
											else{
												echo '<option value="' . $tp->id . '">' . $tp->title . '</option>';
											}
										}
									}
									?>
							</select>
							</label>
						</li>
						<li>
							<label>
							<select name="search_box2" id="district" class="box1_select">
								<option value="0">--Quận huyện --</option>
							</select>
							</label>
						</li>
					</ul>
					<!-- /.localtion_box1 -->
				</div>
				<!-- /.curent_box1 -->
				<!-- /.curent_box1 -->
				<div class="advand_box1">
					<p class="title1">Môn học 2</p>
					<input type="text" class="text_box1"  id="sub2"  value="" placeholder="VD : Toán" />
					<p class="title1">Môn học 3</p>
					<input type="text" class="text_box1" id="sub3"  value="" placeholder="VD : Toán" />
					<p class="title1">Số tiền / Buổi</p>
                    <div class="rate_search clearfix;">
                    <div id="rate_tutor"></div>
                    <p class="clearfix">
                      <input type="text" id="amount" name="amount" class="amount_style"/>
                      <span class="text_advand" style="width: 10px;float:left;">-</span>
                      <input type="text" id="amount2" name="amount2" class="amount_style" />
                      <span class="text_advand">VNĐ</span>
                    </p>
                    </div>
                    <div class="age clearfix">
                    <p class="title1">Độ tuổi</p>
                    <div id="age_tutor"></div>
                    <p>
                      <input type="text" id="amount3" name="amount3" class="amount_style"/>
                    </p>
                    <span class="text_advand" style="width: 10px;float:left;">-</span>
                    <p>
                      <input type="text" id="amount4" name="amount4" class="amount_style" />
                    </p><div style="clear: both;"></div>
                    <p class="title1" style="display: inline-block;">Giới tính</p>
                    <p><select name="gender" id="gender"><option value="3">Tất cả</option><option value="1">Nam</option><option value="0">Nữ</option></select></p>
                    </div>
				</div>
				<!-- /.advand_box1 -->
				<a href="javascript:void(0)" class="btn_box1" title="#">Tìm kiếm</a>
				<a href="javascript:void(0)" class="btn_advand">Tìm kiếm nâng cao</a>
			</div>
			<!-- /.box1 -->
			<?php
			if(!empty($yeucau)) {
				echo $yeucau;
			}
			?>           
		</section>
        
        
  <script>
$(document).ready(function(){
    $('.btn_advand').click(function(){
        $('.advand_box1').toggle(600);
    });
});
</script>
<script>
$(document).ready(function(){
    $('#province').change(function(){
		var province =$('#province').val();
       // Ajax Funtion chọn thành phố
		$.ajax({
			type: "POST",
			url: '<?php echo base_url();?>ajax/index',
			data: {province : province },
			success: success
		});
    });
    function success(data,status){
		$('#district').html(data);
	};
});
</script>
<style>
            .text_advand
            {
                margin-top:5px;
                display:block;
                font-weight:bold;
            }
            .amount_style
            {
                width:60px;
                float:left;
                margin:5px 5px;
                color:#ff9900;
                font-weight:bold;
                border:none;
            }
            </style>
            <script>
              $(function() {
                $( "#rate_tutor" ).slider({
                  range: true,
                  min: 0,
                  max: 1000000,
                  values: [ 0, 500000 ],
                  slide: function( event, ui ) {
                    $( "#amount" ).val(ui.values[ 0 ]);
                    $( "#amount2" ).val(ui.values[ 1 ]);
                  }
                });
                $( "#amount" ).val($( "#rate_tutor" ).slider( "values", 0 ));
                $( "#amount2" ).val($( "#rate_tutor" ).slider( "values", 1 ));
                $( "#age_tutor" ).slider({
                  range: true,
                  min: 0,
                  max: 100,
                  values: [ 18, 45 ],
                  slide: function( event, ui ) {
                    $( "#amount3" ).val(ui.values[ 0 ]);
                    $( "#amount4" ).val(ui.values[ 1 ]);
                  }
                });
                $( "#amount3" ).val($( "#age_tutor" ).slider( "values", 0 ));
                $( "#amount4" ).val($( "#age_tutor" ).slider( "values", 1 ));
              });
          </script>